#include <iostream>
#include <vector>
#include <cstdio> 
#include <map>
#include <set>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
typedef double db;
typedef vector < int >  vec;
typedef pair < int , int > pii;

int read() {
  int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
  while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;

int n,a[N],m,nxt[N];
map < int , int > f;
set < pii > s;

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in,m = in; for(int i = 1;i <= n;i++) a[i] = in;
    for(int i = n;i >= 1;i--)
	nxt[i] = f[a[i]] ? f[a[i]] : n + 1,f[a[i]] = i;
    for(int i = 1;i <= m;i++) s.insert({n + i,0});
    int ans = 0;
    for(int i = 1;i <= n;i++) {
	if(s.find({i,a[i]}) != s.end()) {
	    s.erase({i,a[i]}); s.insert({nxt[i],a[i]});
	} else {
	    ans++; s.erase(*s.rbegin());
	    s.insert({nxt[i],a[i]});
	}
    }
    printf("%d\n",ans); return 0;
} 
